<template>
  <el-dialog
    title="回复评论"
    :visible.sync="visible"
    width="400px"
    :before-close="
      () => {
        $emit('close');
      }
    "
  >
    <el-input v-model="reply" type="textarea" resize="none" rows="6">
    </el-input>
    <span slot="footer" class="dialog-footer">
      <el-button @click="$emit('close')">取 消</el-button>
      <el-button type="primary" @click="afterSaleReply">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { afterSaleReply } from "@/api/order-mng";
export default {
  props: ["visible", "order", "status"],
  data() {
    return {
      reply: null
    };
  },
  watch: {
    visible: function(val) {
      if (val) {
      } else {
        this.reply = null;
      }
    }
  },
  methods: {
    afterSaleReply() {
      if (!this.reply) {
        this.$message({
          message: "请填写回复内容",
          type: "warning"
        });
        return;
      }
      afterSaleReply({
        id: this.order.after.id,
        remake: this.reply,
        status: this.status
      }).then(res => {
        if (res.code === 200) {
          this.$message({
            message: "回复成功",
            type: "success"
          });
          this.$emit("close");
        }
      });
    }
  },
  created() {}
};
</script>

<style lang="scss" scoped></style>
